﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace linQReferencesObject
{
    class Program
    {
        static void Main(string[] args)
        {
            //LogisticsDataContext db = new LogisticsDataContext();
            //var locate = (from loca in db.LG_Locations
            //                where loca.Id == 3
            //                select loca).FirstOrDefault<LG_Location>();
            //List<LG_Branch> listB = locate.LG_Branches.ToList<LG_Branch>();

            //for (int i = 0; i < listB.Count; i++)
            //{
            //    Console.WriteLine(listB.ElementAt<LG_Branch>(i).Date_Installation);
            //}

            ProductsDataContext db = new ProductsDataContext();
            //db.DeferredLoadingEnabled = false;
            var product = (from p in db.Products where p.Id == 3 select p).FirstOrDefault<Product>();
            if (product != null)
            {
                Console.WriteLine(product.Category.Title);
            }
            else
            {
                Console.WriteLine("Product not existing");
            }

            Console.Read();
        }
    }
}
